import state from '../store/state.js';
// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢
const _import = require('./import-' + process.env.NODE_ENV);

function getProps(route) {
  return route.query;
}

// 系统生成路由
const routers = [
  {
    path: '/login',
    component: _import('login/index'),
    name: 'login',
    props: getProps,
    desc: '登录'
  },
  {
    path: '/',
    component: _import('login/index'),
    name: 'root'
  },
  {
    path: '/pipeline',
    component: _import('pipeline/index'),
    name: 'pipeline'
  },
  {
    path: '/pipelineManage',
    component: _import('pipelineManage/index'),
    name: 'pipelineManage'
  },
  {
    path: '/main',
    component: _import('layout/index'),
    name: 'main',
    props: getProps,
    redirect: {
      name: 'welcome'
    },
    meta: {
      title: '主页',
      showOnly: true
    },
    children: [
      {
        path: 'formSysUser',
        component: _import('upms/formSysUser/index'),
        name: 'formSysUser',
        meta: { title: '用户管理' }
      },
      {
        path: '/pipeline1',
        component: _import('pipeline/index'),
        name: 'pipeline1'
      },
      {
        path: 'pipelineManage1',
        component: _import('pipelineManage/index'),
        name: 'pipelineManage1'
      },
      {
        path: 'formSysDept',
        component: _import('upms/formSysDept/index'),
        name: 'formSysDept',
        meta: { title: '部门管理' }
      },
      {
        path: 'formSysRole',
        component: _import('upms/formSysRole/index'),
        name: 'formSysRole',
        meta: { title: '角色管理' }
      },
      {
        path: 'formSysMenu',
        component: _import(
          state.supportColumn ? 'upms/formSysMenu/formSysColumnMenu' : 'upms/formSysMenu/index'
        ),
        name: 'formSysMenu',
        meta: { title: '菜单列表' }
      },
      {
        path: 'formSysDict',
        component: _import('upms/formDictManagement/index'),
        name: 'formSysDict',
        meta: { title: '字典管理' }
      },
      {
        path: 'formSysOperationLog',
        component: _import('upms/formSysOperationLog/index'),
        name: 'formSysOperationLog',
        meta: { title: '操作日志' }
      },
      {
        path: 'formSysLoginUser',
        component: _import('upms/formSysLoginUser/index'),
        name: 'formSysLoginUser',
        meta: { title: '在线用户' }
      },
      // 安全设置
      {
        path: 'formSysConf',
        component: _import('upms/formSysConf/index'),
        name: 'formSysConf',
        meta: { title: '安全设置' }
      },
      {
        path: 'welcome',
        component: _import('welcome/index'),
        name: 'welcome',
        meta: { title: '欢迎' }
      },
      {
        path: 'editLayerField',
        component: _import('formTemplateMng/editLayerField'),
        name: 'editLayerField',
        props: getProps,
        meta: {title: '调查模板字段管理'}
      },
      {
        path: 'listPmDict',
        component: _import('PmDictMng/listPmDict'),
        name: 'listPmDict',
        props: getProps,
        meta: {title: '字典管理'}
      },
      {
        path: 'ListTemplate',
        component: _import('formTemplateMng/listTemplate'),
        name: 'ListTemplate',
        props: getProps,
        meta: { title: '项目模板管理' }
      }
    ]
  },
  // 第三方接入路由
  {
    path: '/thirdParty',
    name: 'thirdParty',
    props: getProps,
    component: _import('thirdParty/index'),
    children: [
      // 通用
      {
        path: 'thirdSelectDept',
        name: 'thirdSelectDept',
        props: getProps,
        component: _import('DeptSelect/deptSelectDlg', 'components')
      },
      {
        path: 'thirdSelectUser',
        name: 'thirdSelectUser',
        props: getProps,
        component: _import('UserSelect/userSelectDlg', 'components')
      },
      {
        path: 'thirdTableCustomQuery',
        name: 'thirdTableCustomQuery',
        props: getProps,
        component: _import('TableBox/CustomQuery/index', 'components')
      },
      {
        path: 'thirdTableCustomConfig',
        name: 'thirdTableCustomConfig',
        props: getProps,
        component: _import('TableBox/CustomConfig/index', 'components')
      }
    ]
  }
];

export default routers;
